﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Core;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.ComponentModel;

namespace Data
{
    public class GetData
    {
        DataProvider ob = new SQLProvider();
        public DataTable GetMaNV(string s)
        {
            DataTable ds = new DataTable();
            string strSQL = "select MaNV from NhanVien where BoPhan = '" + s + "'";
            return ds = ob.Execute_Table(strSQL);
        }
        public DataTable GetDanhMucMaDT(object s)
        {
            DataTable ds = new DataTable();
            string strSQL = "select MaDT from " + s.ToString() + " ";
            return ds = ob.Execute_Table(strSQL);
        }
        public DataTable GetDataTable(object s)
        {
            DataTable ds = new DataTable();
            string strSQL = "Select * from " + s.ToString() + " ";
            return ds = ob.Execute_Table(strSQL);
        }
        public DataTable DataHangBanTheoNgay(string s)
        {
            DataTable ds = new DataTable();
            string strSQL = "select BangPhu.MaDT,count(MaCTHDB)as SoLuong from (select MaCTHDB,MaDT from ChiTietHDB where MaHDB in(select MaHDB from HoaDonBan where NgayBan= '" + s + "'))as BangPhu group by MaDT";
            return ds = ob.Execute_Table(strSQL);
        }
        public DataTable DataHangBanTheoThang(string s)
        {
            DataTable ds = new DataTable();
            string strSQL = "select BangPhu.MaDT,count(MaCTHDB)as SoLuong from (select MaCTHDB,MaDT from ChiTietHDB where MaHDB in(select MaHDB from HoaDonBan where (Month(NgayBan)= Month('" + s + "')) and (Year(NgayBan)= Year('" + s + "'))))as BangPhu group by MaDT";
            return ds = ob.Execute_Table(strSQL);
        }
        public DataTable NgayBan(string s)
        {
            DataTable ds = new DataTable();
            string strSQL = " select NgayBan from HoaDonBan where MaHDB in(select MaHDB from ChiTietHDB where IMEI=" + s + ")";
            return ds = ob.Execute_Table(strSQL);
        }
        public DataTable ThoiGianBaoHanh(string s)
        {
            DataTable ds = new DataTable();
            string strSQL = "select ThoiGianBH from DanhMucDT where MaDT in(select MaDT from ChiTietHDB where IMEI=" + s + ")";
            return ds = ob.Execute_Table(strSQL);
        }
    }
}
